package com.itheima.app.exception;

import com.itheima.vo.ErrorResult;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)//任何异常都交给此方法处理
    public ResponseEntity handleException(Exception ex){
        ex.printStackTrace();

        return ResponseEntity.status(500).body(ErrorResult.error());
    }
}
